<?php

		if (isset($_GET['echostr'])){ //第一次验证服务器用
			$echoStr = $_GET["echostr"];
			if(checkSignature()){
				echo $echoStr;
				exit();
			}
		}else{
			
		}
	
	
	 function checkSignature(){
		$signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];
		$token = "yyh5201314";
		$tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode( $tmpArr );
		$tmpStr = sha1( $tmpStr );
		if( $tmpStr == $signature ){
            return true;
        }else{
            return false;
        }

	}

?>